package com.jz.kufangkuqu.common;

import com.jz.beijianbao.planclass.enumclass.StatusEnum;
import com.jz.kufangkuqu.biaoshi.bean.Status;
import com.jz.kufangkuqu.kufang.service.KuFangService;
import com.jz.kufangkuqu.kuwei.bean.KuWei;
import com.jz.util.ResultBuildVO;
import com.jz.util.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
public class Common {


    //状态下拉框
    @PostMapping("iwm/getPullDownList")
    public ResultVO queryZhuangTai(){
        List<Status> statuses = new ArrayList<>();
        for (StatusEnum statusEnum:StatusEnum.values()) {
            Status status = new Status(statusEnum.getStatus(),statusEnum.getStatusName());
            statuses.add(status);
        }
        return ResultBuildVO.success(statuses);
    }


    @Autowired
    private KuFangService kuFangService;

    //库房标识下拉
    @GetMapping("warehouse/queryWarehouseTagList")
    public ResultVO query(){
        ResultVO resultVO = kuFangService.queryKuFang();
        return resultVO;
    }

    //地区下拉
    @GetMapping("common/getAddressCascade")
    public ResultVO queryDiQu(Integer pid){
        ResultVO resultVO = kuFangService.queryDiQu(pid);
        return resultVO;
    }

    //库房下拉
    @GetMapping("storageSection/queryWareHouse")
    public ResultVO queryKuFangXiaLa(){
        ResultVO resultVO = kuFangService.queryKuFangXiaLa();
        return resultVO;
    }


    //属性下拉
    @GetMapping("storageSection/queryBusinessAttribute")
    public ResultVO queryShuXing(){
        ResultVO resultVO = kuFangService.queryShuXing();
        return resultVO;
    }


    //库区下拉
    @GetMapping("StorageBin/queryStorageSection")
    public ResultVO queryKuQuXiaLa(String id){
        ResultVO resultVO = kuFangService.queryKuQuXiaLa(id);
        return resultVO;
    }
    //库区下拉
    @PostMapping("StorageBin/queryStorageBin")
    public ResultVO queryKuWeiXiaLa(KuWei kuWei){
        ResultVO resultVO = kuFangService.queryKuWeiXiaLa(kuWei);
        return resultVO;
    }


}
